/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.sms.dao;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Component;

import com.chlitina.store.common.persistence.BaseDao;
import com.chlitina.store.common.persistence.BaseDaoImpl;
import com.chlitina.store.modules.sms.entity.SmsSysCustomer;

/**
 * 店面自动发送的短信DAO接口
 * @author lvbo
 * @version 2013-06-21
 */
public interface SmsSysCustomerDao extends SmsSysCustomerDaoCustom, CrudRepository<SmsSysCustomer, Long> {
	
	@Query("from SmsSysCustomer where STORE_ID = ?1 AND PLAN_SEND_TIME BETWEEN ?2 AND ?3")
	public List<SmsSysCustomer> findByParameter(Long storeId, Date start, Date end);
	
	@Query("SELECT SUM(CEIL(CHAR_LENGTH(CONTENT)/?1)) from SmsSysCustomer where STORE_ID = ?2 AND PLAN_SEND_TIME BETWEEN ?3 AND ?4 AND  MESSAGE_TYPE = ?5")
	public Long countByParameter(long defaultLength, Long storeId, Date start, Date end, int messageType);
	
}

/**
 * DAO自定义接口
 * @author lvbo
 */
interface SmsSysCustomerDaoCustom extends BaseDao<SmsSysCustomer> {

}

/**
 * DAO自定义接口实现
 * @author lvbo
 */
@Component
class SmsSysCustomerDaoImpl extends BaseDaoImpl<SmsSysCustomer> implements SmsSysCustomerDaoCustom {

}
